package com.vf.admin.common.jiami;

import com.vf.admin.common.jiami.MD5Utils;

/**
 * api接口鉴权
 */
public class apiSignCreate {

    /**
     * app请求SecretId
     */
    private static final String secretid  = "jyz_app";
    /**
     * app请求SecretKey
     */
    private static final String SecretKey = "8x72141i285f81e58a6c13x85a9eaa58";

    /**
     * 生成Signature
     *
     * @return
     */
    public static String signature(String timeStamp) {
        try {
            return MD5Utils.md5Generate(secretid+SecretKey+timeStamp);
        } catch (Exception e) {
            return null;
        }
    }

    public static boolean signatureVerification(String timeStamp,String signature) {
        try {
            long time=System.currentTimeMillis();
            long between = time -  Long.parseLong(timeStamp);
            if(between<=30000) {
                String sign = MD5Utils.md5Generate(secretid + SecretKey + timeStamp);
                System.out.println("服务器加密:"+sign);
                if (sign.equals(signature)) {
                    return true;
                } else {
                    return false;
                }
            }else{
                return false;
            }
        } catch (Exception e) {
            return false;
        }
    }




}
